package cristiano.rodrigo.luiz.projetoandroidwn;

import java.util.List;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.widget.ArrayAdapter;

public class ListGamesFragment extends ListFragment {

	List<Game> games;
	EventoDeCliqueNoGame listener;
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		refresh();
	}
	
	public void refresh(){
		GamesDB gamesdb = new GamesDB(getActivity());
		
		games = gamesdb.getGames();
		
		setListAdapter(new ArrayAdapter<Game>(
				getActivity(), android.R.layout.simple_list_item_1,games));
	}
	
	public void setListener(EventoDeCliqueNoGame listener) {
		this.listener = listener;
	}
	
	public interface EventoDeCliqueNoGame{
		void GameClicado(Game g, int posicao);
	}
}
